import sys
from PyQt4 import QtCore, QtGui
import transform_editor_base 
from lucid.util.qt.Wheel import Wheel

class Ui_TransformEditorBase2(transform_editor_base.Ui_TransformEditorBase):
   """ Customized editor.  We change the base by introducing wheel. """
   def setupUi(self, TransformEditorBase):
      transform_editor_base.Ui_TransformEditorBase.setupUi(self,TransformEditorBase)

      # Replace all sliders with wheels
      # - Rename var to end in wheel
      for (grid_name, slider_names) in [ ('gridlayout',
               ["mXTranslationSlider","mYTranslationSlider","mZTranslationSlider"]),
               ('gridlayout1',["mXRotationSlider","mYRotationSlider","mZRotationSlider"]),
               ('gridlayout2',["mXScaleSlider","mYScaleSlider","mZScaleSlider"])]:
         for slider_name in slider_names:
            slider = getattr(self,slider_name)
            grid = getattr(self,grid_name)
            assert (slider and grid)
            
            slider_index = grid.indexOf(slider)
            slider_location = grid.getItemPosition(slider_index)
            grid.removeWidget(slider)
            slider.setParent(None)
            delattr(self,slider_name)
            
            wheel_name = slider_name.replace("Slider","Wheel")
            wheel = Wheel(TransformEditorBase)
            wheel.setRange(-1000.0, 1000.0, 1.0, 1.0)
            grid.addWidget(wheel, *slider_location)
            setattr(self,wheel_name, wheel)
            

if __name__ == "__main__":
   app = QtGui.QApplication(sys.argv)
   TransformEditorBase = QtGui.QWidget()
   ui = Ui_TransformEditorBase2()
   ui.setupUi(TransformEditorBase)
   TransformEditorBase.show()
   sys.exit(app.exec_())
